<!--
 * @Description: 租户管理
 * @Version: 1.0
 * @Autor: chen_yt
 * @Date: 2022-07-11 13:43:40
 * @LastEditors: chen_yt
 * @LastEditTime: 2022-08-09 14:23:34
-->
<template>
  <component :is="getMainComponent"></component>
</template>
<script>
import { IS_SAAS_MODE } from '@/store/Getter/getterTypes.js'
import Mix from '@/mixins/module'
import { saasPermission } from '@/saas/util'
import { SAAS_TYPE } from '@/config/enums'

export default {
  name: 'Tenant',
  mixins: [Mix],
  computed: {
    getMainComponent() {
      if (this.$store.getters[IS_SAAS_MODE]) {
        return () => import('./mainComponent/saas')
      }
      return () => import('./mainComponent/saas')
      // 若非saas模式下需要使用旧的租户管理，请使用下方return的组件
      // return () => import('./mainComponent/notSaas')
    }
  },
  //普通租户和非saas模式下阻止进入租户管理
  //非saas下想进入请去掉SAAS_TYPE.NOT_SAAS
  beforeRouteEnter(to, from, next) {
    if (saasPermission([SAAS_TYPE.TENANT, SAAS_TYPE.NOT_SAAS])) {
      next('/404')
      return
    }
    next()
    return
  }
}
</script>